<%@page import="com.dfhc.ISystemConstant"%>
<%@page import="org.quickbundle.orgauth.cache.RmPartyTypeCache"%>
<%@page import="org.quickbundle.orgauth.IOrgauthConstants"%>
<%@page import="com.dfhc.rm.user.IUserConstants"%>
<%@page import="org.quickbundle.orgauth.rmuser.util.IRmUserConstants"%>
<%@ page import="org.quickbundle.orgauth.rmuseronlinerecord.vo.RmUserOnlineRecordVo" %>
<%@ page import="org.quickbundle.orgauth.rmuseronlinerecord.util.IRmUserOnlineRecordConstants" %>

<%@page import="com.dfhc.util.CryptoHelper"%>
<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/h-ui/add.css" />
<script type="text/javascript" src="${pageContext.request.contextPath }/js/new/newjs/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/new/newjs/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/new/newjs/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/new/newjs/laypage.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/new/newjs/WdatePicker.js"></script>
<!-- 全局js 和css包 -->
<%@ include file="/jsp/include/web/new/global.jsp" %>
<title>用户管理</title>
<!--/meta 作为公共模版分离出去-->
<link rel="stylesheet" href="<%=request.getContextPath() %>/css/ztree/demo.css" type="text/css">
<link rel="stylesheet" href="<%=request.getContextPath() %>/css/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="<%=request.getContextPath() %>/js/ztree/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/ztree/jquery.ztree.excheck-3.5.js"></script>

<script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath() %>/js/new/js/map.js"></script>
<title>添加用户 </title>

<%@ taglib uri="/dfhc" prefix="dfhc" %>
</head>		
<body>


	<article class="page-container">

	<form action="" method="post" class="form form-horizontal" id="form-member-add" >
		<input type="hidden" name="view_id" value="<%=IOrgauthConstants.PartyView.DEFAULT.id() %>" id="view_id"></input>
		<input type="hidden" name="isInherit" value="0"></input>
		<input type="hidden" name="party_type_id"  value="<%=IOrgauthConstants.Config.isUserRelationParty.value() && RmPartyTypeCache.getPartyType(IRmUserConstants.TABLE_NAME) != null ? RmPartyTypeCache.getPartyType(IRmUserConstants.TABLE_NAME).getId() : ""%>"/>	
		<input type="hidden" id="id" name="id" value="${bean.id}">
	    <dfhc:div templateId="h_ui_div_row_cl">
	    <dfhc:title templateId="h_ui_label_title"><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("name")%>：</dfhc:title>	    
	    <dfhc:div templateId="h_ui_div_fromcontrol">	        
			<dfhc:input templateId="h_ui_input" value="${bean.name}" placeholder="" id="name" name="name" readonly="true" />			
		</dfhc:div>	    		 
	    </dfhc:div>
		<dfhc:div templateId="h_ui_div_row_cl">
			<dfhc:title templateId="h_ui_label_title"><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("lock_status")%>:</dfhc:title>
			<dfhc:div templateId="h_ui_div_fromcontrol">
				<dfhc:select templateId="h_ui_select" size="1" name="lock_status" id="lock_status" pleaseSelect="1" defaultValue="${bean.lock_status}" sqlOption="code" code="<%=IRmUserConstants.DICTIONARY_RM_LOCK_STATUS%>" readonly="true" />				
			</dfhc:div>
		</dfhc:div>
		<dfhc:div templateId="h_ui_div_row_cl">
			<dfhc:title templateId="h_ui_label_title"><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("login_id")%>：</dfhc:title>
			<dfhc:div templateId="h_ui_div_fromcontrol">
				<dfhc:input templateId="h_ui_input" value="${bean.login_id}" id="loginId" name="loginId" readonly="true" />
			</dfhc:div>
		</dfhc:div>
		<dfhc:div templateId="h_ui_div_row_cl">
			<dfhc:title templateId="h_ui_label_title"><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("email")%>：</dfhc:title>
			<dfhc:div templateId="h_ui_div_fromcontrol">				
				<dfhc:input templateId="h_ui_input" value="${bean.email}" id="email" name="email" readonly="true" />
			</dfhc:div>
		</dfhc:div>
		<dfhc:div templateId="h_ui_div_row_cl">
			<dfhc:title templateId="h_ui_label_title">描述：</dfhc:title>
			<dfhc:div templateId="h_ui_div_fromcontrol">			    
				<dfhc:textarea name="description" cols="" rows="" maxlength="100" templateId="h_ui_textarea" readonly="true" >${bean.description}</dfhc:textarea>				
			</dfhc:div>
		</dfhc:div>
		<dfhc:div templateId="h_ui_div_row_cl">
			<dfhc:title templateId="h_ui_label_title"><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("admin_type")%>:</dfhc:title>
			<dfhc:div templateId="h_ui_div_fromcontrol">
				<dfhc:select templateId="h_ui_select" size="1" name="lockStatus" id="lockStatus" pleaseSelect="1" defaultValue="${bean.admin_type}" sqlOption="code" code="<%=IRmUserConstants.DICTIONARY_RM_ADMIN_TYPE%>" readonly="true" />				
			</dfhc:div>
		</dfhc:div>
		<dfhc:div templateId="h_ui_div_row_cl">
			<dfhc:div templateId="h_ui_div_pop_up_button">
				<dfhc:button templateId="h_ui_update_button" onclick="_Edit('修改用户','${pageContext.request.contextPath }/newRmUser/showPage','','550','${bean.id }')" />
				<dfhc:button templateId="h_ui_back_button" onclick="_back()" />
			</dfhc:div>
		</dfhc:div>
	</form>
	<br>
	<br>
	<dfhc:table templateId="table_h_ui"  align="center" border="1">
		<dfhc:tr>
		<dfhc:td >本用户所属组织</dfhc:td>
		</dfhc:tr>
		<!--这是第一行-->
		<dfhc:tr>
		<dfhc:td  >${bean.custom4 }</dfhc:td>
		</dfhc:tr>
		<!--这是第二行-->
		<dfhc:tr>
		<dfhc:td >${bean.custom3 }</dfhc:td>
		</dfhc:tr>
	</dfhc:table>
</article>
		
<div id="tab_demo" class="HuiTab">
  <div class="tabBar clearfix"><span id="a" >用户在线记录</span><span id="b" >数据权限分公司</span><span id="c" >数据权限编码类型</span></div>
  <div class="tabCon">
 <dfhc:template templateUrl="/pubController/getLayoutTemp/?jspUrl=/temp/huiBodyTemp" >	 
 	<dfhc:region name="searchRegion"> 
	<form name="searchForm" id="searchForm" action="">
 	<dfhc:div templateId="h_ui_div_search">
 		用户ID:
		<dfhc:input templateId="h_ui_search_input" id="user_id" name="user_id" value="" />
		集群节点ID:
		<dfhc:input templateId="h_ui_search_input" placeholder="集群节点ID" id="cluster_node_id" name="cluster_node_id"/>
		客户端会话标识：
		<dfhc:input templateId="h_ui_search_input" placeholder="客户端会话标识" id="login_sign" name="login_sign"/>
		登录IP:
		<dfhc:input templateId="h_ui_search_input" placeholder="登录IP" id="login_ip" name="login_ip"/>
		<dfhc:button templateId="h_ui_search_button"  onclick="javascript:_searchData();" />
		<dfhc:button templateId="h_ui_search_button"  onclick="javascript:_reset('#searchForm');" />
	</dfhc:div> 
	</form>
     </dfhc:region> 
     <dfhc:region name="buttonRegion">
        <dfhc:div templateId="h_ui_div_table_button">
        <dfhc:span templateId="h_ui_button_span">
		 <dfhc:button templateId="h_ui_delete_button" onclick="singleDelete('/newOnlineRmUser/delete')" />
		</dfhc:span>
		<dfhc:span templateId="h_ui_total_record_num_span">${RM_PAGE_VO.recordCount}</dfhc:span>		
	    </dfhc:div>		       
     </dfhc:region> 
    <dfhc:region name="tableRegion">
    	<dfhc:table templateId="table_h_ui" id="tableon" >    	
		<dfhc:thead>
			<dfhc:tr> 
				<dfhc:th width="25">
				   <dfhc:checkbox name="allId" />
				</dfhc:th>	
				
				<dfhc:th >
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserOnlineRecordConstants.TABLE_COLUMN_CHINESE.get("user_id")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th >
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserOnlineRecordConstants.TABLE_COLUMN_CHINESE.get("login_time")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th >
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserOnlineRecordConstants.TABLE_COLUMN_CHINESE.get("cluster_node_id")%></dfhc:title>
				</dfhc:th>
				<dfhc:th >
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserOnlineRecordConstants.TABLE_COLUMN_CHINESE.get("login_sign")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th >
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserOnlineRecordConstants.TABLE_COLUMN_CHINESE.get("login_ip")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th >
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserOnlineRecordConstants.TABLE_COLUMN_CHINESE.get("login_uuid")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th >
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserOnlineRecordConstants.TABLE_COLUMN_CHINESE.get("logout_time")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th >
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserOnlineRecordConstants.TABLE_COLUMN_CHINESE.get("logout_type")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th >
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserOnlineRecordConstants.TABLE_COLUMN_CHINESE.get("online_time")%></dfhc:title>
				</dfhc:th>
			</dfhc:tr>
    	   </dfhc:thead>			
		</dfhc:table>           
     </dfhc:region>        
     <dfhc:region name="footer"> 
     </dfhc:region> 
</dfhc:template> 
  </div>
  <div class="tabCon">
 <dfhc:template templateUrl="/pubController/getLayoutTemp/?jspUrl=/temp/huiBodyTemp" >	 
 	<dfhc:region name="searchRegion">
 	</dfhc:region>
     <dfhc:region name="buttonRegion">
        <input type="hidden" id="authorizeResourceIds" />
        <input type="hidden" id="authorizeResourceNames" />
        <dfhc:div templateId="h_ui_div_table_button">
        <dfhc:span templateId="h_ui_button_span">
         <dfhc:button templateId="h_ui_add_button" onclick="showAuthorizeResource('增加所属公司数据权限','/rmauthorizeresource/referencePage','500','500');" /> 
		 <dfhc:button templateId="h_ui_delete_button" onclick="deleteAuthorizeResource()" />
		</dfhc:span>
		<dfhc:span templateId="h_ui_total_record_num_span">${RM_PAGE_VO.recordCount}</dfhc:span>		
	    </dfhc:div>	       
     </dfhc:region> 
    <dfhc:region name="tableRegion">
    	<dfhc:table templateId="table_h_ui" id="tabletw" >    	
		<dfhc:thead>
			<dfhc:tr> 
				<dfhc:th >
				   <dfhc:checkbox name="allId" />
				</dfhc:th>	
				
				<dfhc:th >
				   <dfhc:title templateId="title_h_ui" >名称：</dfhc:title>
				</dfhc:th>
			</dfhc:tr>
    	   </dfhc:thead>			
		</dfhc:table>           
     </dfhc:region>        
     <dfhc:region name="footer"> 
     </dfhc:region> 
</dfhc:template> 
  </div>
  <div class="tabCon">
   <dfhc:template templateUrl="/pubController/getLayoutTemp/?jspUrl=/temp/huiBodyTemp" >
   <dfhc:region name="searchRegion">
 	</dfhc:region>	 
     <dfhc:region name="buttonRegion">
        <dfhc:div templateId="h_ui_div_table_button">
        <dfhc:span templateId="h_ui_button_span">
         <dfhc:button templateId="h_ui_add_button" onclick="_showPage()" /> 
		 <dfhc:button templateId="h_ui_delete_button" onclick="singleDelete('/newRmUser/delete')" />
		</dfhc:span>
		<dfhc:span templateId="h_ui_total_record_num_span">${RM_PAGE_VO.recordCount}</dfhc:span>		
	    </dfhc:div>	       
     </dfhc:region> 
    <dfhc:region name="tableRegion">
    	<dfhc:table templateId="table_h_ui" id="tableth" >    	
		<dfhc:thead>
			<dfhc:tr> 
				<dfhc:th width="25">
				   <dfhc:checkbox name="allId" />
				</dfhc:th>	
				
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" >名称：</dfhc:title>
				</dfhc:th>
			</dfhc:tr>
    	   </dfhc:thead>			
		</dfhc:table>           
     </dfhc:region>        
     <dfhc:region name="footer"> 
     </dfhc:region> 
</dfhc:template> 
  </div>
</div>



<script type="text/javascript">
var url;
var 	_table1;
var 	_table2;
var     _table3;
$(function(){
	$.Huitab("#tab_demo .tabBar span","#tab_demo .tabCon","current","click","0")
	
		var ids='${bean.id}';
		url='<%=CryptoHelper.encryptUrl(request,"/newOnlineRmUser/onlineUserajaxList")%>';
		anewUrl = url+'?user_id='+ids;
		_table1 = $('#tableon').dataTable({	
	     dom: 'Zlfrtip',	 
	     
		 ajax : function(data, callback, settings) {
		       var param =  splitParameter(data); 
		       
               $.ajax({  
                      type: "POST",  
                      url: getRootPath()+anewUrl,  
                      cache : false,  //禁用缓存  
                      data:param,   
                      dataType: "json",  
                      success: function(result) {  
                              //异常判断与处理  
                              if (result.status=='0') {  
                                  alert(result.message);  
                                  return;  
                              }  
                              //封装返回数据  
                              var returnData = {};  
                              returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回  
                              returnData.recordsTotal = result.recordsTotal;//总记录数  
                              returnData.recordsFiltered = result.recordsTotal;//后台不实现过滤功能，每次查询均视作全部结果  
                              returnData.data = result.data;  
                              //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染  
                              //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕  
                              callback(returnData);  
                              //更新总记录数
                              $("#totalRecodSpan").html('共有数据：<strong>'+result.recordsTotal+'</strong> 条</span>');
                      },  
                      error: function(XMLHttpRequest, textStatus, errorThrown) {  
                          alert("查询失败");  
                      }  
                  });   
          },  
		"columns": [
		  {
		    "data":"id",
			"render":function(data,type,row,meta){
			   var content='<input type="checkbox" name="allId" value="'+row.id+'"/>';
			   return content; 
			}
		  },
		  {"data":"user_id"},
		  {	   
			"data":"login_time",
			"defaultContent":"",
			render:function(data,type,row,meta){
			var content=formatDate(row.createTime,'yyyy-MM-dd');			 
			return content; 
				}
			  },
		  {"data":"cluster_node_id"},
		  {"data":"login_sign"},
		  {"data":"login_ip"},
		  {"data":"login_uuid"},
		  {
			  "data":"logout_time",
			  "defaultContent":"",
				render:function(data,type,row,meta){
				var content=formatDate(row.createTime,'yyyy-MM-dd');			 
				return content; 
				}
			  },
		  {"data":"logout_type"},
		  {	   
		    "data":"online_time",
		    "defaultContent":"",
			render:function(data,type,row,meta){
			   var content=formatDate(row.createTime,'yyyy-MM-dd');			 
			   return content; 
			}
		  }  
		],
		"columnDefs": [ {"searchable": false,
          "orderable": false,
          "targets": 0 }]  				
	});
	//点击选择组织,
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	$('#b').click(function(){
		debugger;
		var ids='${bean.id}';
		url='<%=CryptoHelper.encryptUrl(request,"/newOnlineRmUser/ajaxAuthorizeResourceList")%>';
		newUrl2 = url+'?party_id='+ids+'&bs_keyword=<%=IOrgauthConstants.Authorize.BRANCH_COMPANY.bsKeyword()%>';
		gotourl2(newUrl2);
	});
	$('#c').click(function(){
		debugger;
		var ids='${bean.id}';
		url='<%=CryptoHelper.encryptUrl(request,"/newOnlineRmUser/ajaxAuthorizeResourceList")%>';
		newUrl3 = url+'?party_id='+ids+'&bs_keyword=<%=IOrgauthConstants.Authorize.RM_CODE_TYPE.bsKeyword()%>';
		gotourl3(newUrl3);
	});
	
});

jQuery.Huitab =function(tabBar,tabCon,class_name,tabEvent,i){
	var $tab_menu=$(tabBar);
	  // 初始化操作
	  $tab_menu.removeClass(class_name);
	  $(tabBar).eq(i).addClass(class_name);
	  $(tabCon).hide();
	  $(tabCon).eq(i).show();
	  
	  $tab_menu.bind(tabEvent,function(){
	$tab_menu.removeClass(class_name);
	$(this).addClass(class_name);
	var index=$tab_menu.index(this);
	$(tabCon).hide();
	$(tabCon).eq(index).show()})
}
/**
 * 查询用户
 */
function _searchData(){	
	$('.table-sort').DataTable().ajax.reload();
}

function gotourl2(url){
	debugger;
	_table2 = $('#tabletw').dataTable({	
	     dom: 'Zlfrtip',
		 ajax : function(data, callback, settings) {
		       var param =  splitParameter(data); 
		       
                $.ajax({  
                       type: "POST",  
                       url: getRootPath()+url,  
                       cache : false,  //禁用缓存  
                       data:param,   
                       dataType: "json",  
                       success: function(result) {  
                               //异常判断与处理  
                               if (result.status=='0') {  
                                   alert(result.message);  
                                   return;  
                               }  
                               //封装返回数据  
                               var returnData = {};  
                               returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回  
                               returnData.recordsTotal = result.recordsTotal;//总记录数  
                               returnData.recordsFiltered = result.recordsTotal;//后台不实现过滤功能，每次查询均视作全部结果  
                               returnData.data = result.data;  
                               //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染  
                               //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕  
                               callback(returnData);  
                               //更新总记录数
                               $("#totalRecodSpan").html('共有数据：<strong>'+result.recordsTotal+'</strong> 条</span>');
                       },  
                       error: function(XMLHttpRequest, textStatus, errorThrown) {  
                           alert("查询失败");  
                       }  
                   });   
           },  
           "destroy": true,
		"columns": [
		  {
		    "data":"id",
			"render":function(data,type,row,meta){
			   var content='<input type="checkbox" name="allId" value="'+row.id+'"/>';
			   return content; 
			}
		  },
		  {"data":"rm_display_column"}
		],
		"columnDefs": [ {"searchable": false,
           "orderable": false,
           "targets": 0 }]  				
	});
	//点击选择组织,
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
}

function gotourl3(url){
	debugger;
	_table3 = $('#tableth').dataTable({	
	     dom: 'Zlfrtip',
		 ajax : function(data, callback, settings) {
		       var param =  splitParameter(data); 
		       
                $.ajax({  
                       type: "POST",  
                       url: getRootPath()+url,  
                       cache : false,  //禁用缓存  
                       data:param,   
                       dataType: "json",  
                       success: function(result) {  
                               //异常判断与处理  
                               if (result.status=='0') {  
                                   alert(result.message);  
                                   return;  
                               }  
                               //封装返回数据  
                               var returnData = {};  
                               returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回  
                               returnData.recordsTotal = result.recordsTotal;//总记录数  
                               returnData.recordsFiltered = result.recordsTotal;//后台不实现过滤功能，每次查询均视作全部结果  
                               returnData.data = result.data;  
                               //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染  
                               //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕  
                               callback(returnData);  
                               //更新总记录数
                               $("#totalRecodSpan").html('共有数据：<strong>'+result.recordsTotal+'</strong> 条</span>');
                       },  
                       error: function(XMLHttpRequest, textStatus, errorThrown) {  
                           alert("查询失败");  
                       }  
                   });   
           },  
           "destroy": true,
		"columns": [
		  {
		    "data":"id",
			"render":function(data,type,row,meta){
			   var content='<input type="checkbox" name="allId" value="'+row.id+'"/>';
			   return content; 
			}
		  },
		  {"data":"rm_display_column"}
		],
		"columnDefs": [ {"searchable": false,
           "orderable": false,
           "targets": 0 }]  				
	});
	//点击选择组织,
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
}

function _back(){
	window.location.href='<%=request.getContextPath()%><%=CryptoHelper.encryptUrl(request,"/orgauth/rmuser/listNewRmUser.jsp")%>';
}



function _Edit(title,url,w,h,id){
	var neww;
    var newh;
    var newUrl;
    if(w.indexOf("%")!=-1){
      neww = w; 
    }else{
      neww = w+'px';
    }
    if(h.indexOf("%")!=-1){
      newh = h; 
    }else{
      newh = h+'px';
    }
    newUrl=url+'?id='+id;
	layer.open({
			type: 2,
			area: [neww, newh],
			fix: true,
			shade:0.4,
			title: title,
			content: getRootPath()+newUrl,
            maxmin:true,
			cancel:function(){
				window.location.reload();
			}
	});
}
//单条删除
function singleDelete(url){
	//判断是否选择
	var len = $('input[name="allId"]:checked').length;
    var count=0;
    var ids='';
     $('input[name="allId"]:checked').each(function(){     	
     	var dataId =$(this).val();
     	if(dataId !== undefined && dataId!='on'){
     		ids+=dataId
         	if(len!=1){
         		ids+=","
         	}
         	count++;
     	}
     });  
    if(count==0){
       alert("请选择删除的记录!");
       return;
    }  
    
    if(count>1){
       alert("只能选择一条记录!");
       return;	
    }
    var newUrl ;
    if(url.indexOf("?")>=0){
    	newUrl = url+'&id='+ids+'&jsguid='+ids;
    }else{
    	newUrl = url+'?id='+ids+'&jsguid='+ids;
    }
    //url 后面自动带csrf 编码
	if(!isStrEmpty($('#_csrfcode_').val())){
		if (newUrl.indexOf("?") == -1) {
			newUrl = newUrl + "?_csrfcode_=" + $('#_csrfcode_').val();
		} else {
			newUrl = newUrl + "&_csrfcode_=" + $('#_csrfcode_').val();
		}
	}
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: getRootPath()+newUrl,
			dataType: 'json',
			success: function(data){
				//更新随机码
				$("#_csrfcode_").val(data._csrfcode_);
				//$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
				$('.table-sort').DataTable().ajax.reload();
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}



//显示授权资源参照
function showAuthorizeResource(title,url,w,h){
	var backFillExpression=[{id:"authorizeResourceIds",column:"0"},{id:"authorizeResourceNames",column:"1"}];
    var filterExpression = "bs_keyword="+bsKeyWord;
	var neww;
    var newh;
    var newUrl;
    var bsKeyWord = "<%=IOrgauthConstants.Authorize.BRANCH_COMPANY.bsKeyword()%>";
    if(w.indexOf("%")!=-1){
      neww = w; 
    }else{
      neww = w+'px';
    }
    if(h.indexOf("%")!=-1){
      newh = h; 
    }else{
      newh = h+'px';
    }
    newUrl=url+'?bs_keyword='+bsKeyWord;
	layer.open({
			type: 2,
			area: [neww, newh],
			fix: true,
			shade:0.4,
			title: title,
			btn: ['确定','关闭'],			
			content: getRootPath()+newUrl,
            maxmin:true,
			yes:function(index){
				 var res = window["layui-layer-iframe" + index].confirmReferenceAuthorizeResourceContent(backFillExpression,'1');
				 //从隐藏变量里取出返回值，循环通过js循环插入表格
				 if(res){
				 	 ajaxBatchInsert("${bean.id}",$("#authorizeResourceIds").val(),"<%=IOrgauthConstants.Authorize.BRANCH_COMPANY.bsKeyword()%>");				 	 	
				 }
				 layer.close(index);
			}
	});
}
//批量数据权限授权
function ajaxBatchInsert(party_id,old_resource_ids,bs_keyword){
	var url='<%=CryptoHelper.encryptUrl(request,"/rmauthorizeresource/ajaxBatchInsert")%>?_csrfcode_='+$("#_csrfcode_").val()+'&<%=ISystemConstant.JSGUID%>='+party_id;
	$.ajax({
			type: 'POST',
			url: getRootPath()+url,
			dataType: 'json',
			data:{party_id:party_id,bs_keyword:bs_keyword,old_resource_ids:old_resource_ids},
			success: function(data){
				//更新随机码
				$("#_csrfcode_").val(data._csrfcode_);
				layer.msg(data.message,{icon:1,time:1000});
				if(data.status=='1'){
					$('#tabletw').DataTable().ajax.reload();
				}
			},
			error:function(data) {
				layer.msg('数据授权失败!',{icon:1,time:1000});
				console.log(data.msg);
			},
		});		
}
//删除数据权限
function deleteAuthorizeResource(){
	var bs_keyword='<%=IOrgauthConstants.Authorize.BRANCH_COMPANY.bsKeyword()%>';
	var url='<%=CryptoHelper.encryptUrl(request,"rmauthorizeresource/ajaxDeleteAuthorizeResource")%>?_csrfcode_='+$("#_csrfcode_").val();
	
	//判断是否选择
	var len = $('#tabletw input[name="allId"]:checked').length;
    var count=0;
    var ids='';
     $('#tabletw input[name="allId"]:checked').each(function(){     	
     	var dataId =$(this).val();
     	if(dataId !== undefined && dataId!='on'){
     		ids+="'"+dataId+"'"
         	if(len!=1){
         		ids+=","
         	}
         	count++;
     	}
     });  
    if(count==0){
       alert("请选择删除的记录!");
       return;
    }  
    //去掉最后的,
    if(ids.indexOf(",")!=-1){
    	ids= ids.substring(0,ids.length-1);
    }
    /*if(count>1){
       alert("只能选择一条记录!");
       return;	
    }*/
	$.ajax({
			type: 'POST',
			url: getRootPath()+url,
			dataType: 'json',
			data:{party_ids:'${bean.id}',bs_keyword:bs_keyword,id:ids},
			success: function(data){
				//更新随机码
				$("#_csrfcode_").val(data._csrfcode_);
				layer.msg(data.message,{icon:1,time:1000});
				if(data.status=='1'){
					$('#tabletw').DataTable().ajax.reload();
				}
			},
			error:function(data) {
				layer.msg('删除数据权限失败!',{icon:1,time:1000});
				console.log(data.msg);
			},
		});		
		
}
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>